// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.


Type.registerNamespace("GridControl");
var $CurTabPanel;
GridControl.TabContainer = function(element) {
    GridControl.TabContainer.initializeBase(this, [element]);
    this._active = false;
    this._tab = null;
    this._headerOuter = null;
    this._headerInner = null;
    this._header = null;
    this._owner = null;
    this._enabled = true;
    this._tabIndex = -1;
}
GridControl.TabContainer.prototype = {
    get_headerText : function() { 
        if (this.get_isInitialized()) {
            return this._header.innerHTML;
        }
        return ""; 
    },
    set_headerText : function(value) { 
        if (!this.get_isInitialized()) {
            throw Error.invalidOperation(String.format(AjaxControlToolkit.Resources.Tabs_PropertySetBeforeInitialization, 'headerText'));
        }
        if (this._headerText != value) {
            this._headerTab.innerHTML = value;
            this.raisePropertyChanged("headerText");
        }
    },
    
    get_headerTab : function() {
        return this._header;
    },
    set_headerTab : function(value) {
        if (this._header != value) {
            if (this.get_isInitialized()) {
                throw Error.invalidOperation(String.format(AjaxControlToolkit.Resources.Tabs_PropertySetAfterInitialization, 'headerTab'));
            }
            this._header = value;
            this.raisePropertyChanged("value");
        }
    },
        
    get_enabled : function() {
        return this._enabled;
    },
    set_enabled : function(value) {
        if (value != this._enabled) {
            this._enabled = value;
            if (this.get_isInitialized()) {
                if (!this._enabled) {
                    this._hide();
                } else {
                    this._show();
                }
            }
            this.raisePropertyChanged("enabled");
        }
    },
    
    get_owner : function() {
        return this._owner;
    },
    set_owner : function(value) {
        if (this._owner != value) {
            if (this.get_isInitialized()) {
                throw Error.invalidOperation(String.format(AjaxControlToolkit.Resources.Tabs_PropertySetAfterInitialization, 'owner'));
            }
            this._owner = value;
            this.raisePropertyChanged("owner");
        }
    },
    get_tabIndex : function() {
        return this._tabIndex;
    },
    
    _get_active : function() { 
        return this._active; 
    },
    _set_active : function(value) { 
        this._active = value; 
        if (value) 
            this._activate(); 
        else 
            this._deactivate();
    },
    get_DynamicContentPath:function(){
        return this._DynamicContentPath;
    },
    set_DynamicContentPath:function(value){
        this._DynamicContentPath=value;
    },
    initialize : function() {
        GridControl.TabContainer.callBaseMethod(this, "initialize");
        var id=this.get_element().id;
        var jtabs; 
        var hd=this.get_headerTab();
        //the main tab
        
        var owner = this.get_owner();
        //
        var bd=document.getElementById(owner+"_body");
        var elOwner=document.getElementById(owner);
        elOwner.style.height=bd.style.height;
        elOwner.style.width=bd.style.width;
        if($CurTabPanel==null){
            jtabs = new Ext.TabPanel(owner);  
            var tab3 = jtabs.addTab(id, hd.innerHTML);
           
            $CurTabPanel=jtabs;
            
            jtabs.activate(id);
        }
        else{
            jtabs=$CurTabPanel;
            var tab3 = jtabs.addTab(id, hd.innerHTML);
          
        }
        var headers=document.getElementById(owner+"_header");
        headers.style.display='none';
        bd.style.display="none";
        //document.removeChild();
        //hd.style.display='none';
        
       
    }

  
    
  
}
GridControl.TabContainer.registerClass("GridControl.TabContainer", Sys.UI.Control);
